#!/bin/bash
REMOTE=$1
SSH_OPTS=" -x -q -o ConnectTimeout=15 -o BatchMode=yes -o StrictHostKeyChecking=no -o LogLevel=fatal"
echo "Adding remote root login for host $REMOTE"
cat <<-'EOF' | if [ "$REMOTE" != "localhost" ]; then sudo -u saunix ssh $SSH_OPTS $REMOTE "cat | sudo /bin/bash"; else cd /tmp; cat | sudo /bin/bash; fi
	/usr/local/scripts/bk /etc/ssh/sshd_config
	cat /etc/ssh/sshd_config | grep -v 'PermitRootLogin' > /tmp/tmpsshd
	echo PermitRootLogin yes >> /tmp/tmpsshd && sudo mv /tmp/tmpsshd /etc/ssh/sshd_config
	kill -HUP `ps -ef|grep sshd | grep [/]usr/sbin/sshd | tail -1 | awk '{print $2}'`
EOF
